package website.seamonster.ethegg.dataobject;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

/**
 * Created by 罗海量
 * 2018-07-19 21:31
 */
@Entity
@Table(name = "sys_user")
@Slf4j
@Data
@DynamicInsert
@DynamicUpdate
public class User {

    private String id;
    private String userName;
    private Integer maxHatch;
    private String prCode;
    private Timestamp createTime;
    private Timestamp prActiveTime;
    private Timestamp prEndTime;
    private long version;

    @Id
    @Column(name = "ID")
    @GenericGenerator(name = "user-uuid", strategy = "uuid")
    @GeneratedValue(generator = "user-uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "user_name")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Basic
    @Column(name = "max_hatch")
    public Integer getMaxHatch() {
        return maxHatch;
    }

    public void setMaxHatch(Integer maxHatch) {
        this.maxHatch = maxHatch;
    }

    @Basic
    @Column(name = "pr_code")
    public String getPrCode() {
        return prCode;
    }

    public void setPrCode(String prCode) {
        this.prCode = prCode;
    }

    @Basic
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "pr_active_time")
    public Timestamp getPrActiveTime() {
        return prActiveTime;
    }

    public void setPrActiveTime(Timestamp prActiveTime) {
        this.prActiveTime = prActiveTime;
    }

    @Basic
    @Column(name = "pr_end_time")
    public Timestamp getPrEndTime() {
        return prEndTime;
    }

    public void setPrEndTime(Timestamp prEndTime) {
        this.prEndTime = prEndTime;
    }

    @Basic
    @Column(name = "VERSION")
    public long getVersion() {
        return version;
    }

    public void setVersion(long version) {
        this.version = version;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return version == user.version &&
                Objects.equals(id, user.id) &&
                Objects.equals(userName, user.userName) &&
                Objects.equals(maxHatch, user.maxHatch) &&
                Objects.equals(prCode, user.prCode) &&
                Objects.equals(createTime, user.createTime) &&
                Objects.equals(prActiveTime, user.prActiveTime) &&
                Objects.equals(prEndTime, user.prEndTime);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, userName, maxHatch, prCode, createTime, prActiveTime, prEndTime, version);
    }
}
